# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

_realname=pallets-sphinx-themes
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.1.3
pkgrel=2
pkgdesc="Sphinx themes for Pallets and related projects (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
license=('BSD')
url='https://github.com/pallets/pallets-sphinx-themes'
msys2_references=(
  'purl: pkg:pypi/pallets-sphinx-themes'
)
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-packaging"
         "${MINGW_PACKAGE_PREFIX}-python-sphinx")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-flit-core"
             "${MINGW_PACKAGE_PREFIX}-python-installer")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname/-/_}/${_realname//-/_}-${pkgver}.tar.gz")
sha256sums=('853ccdc2698ab0a2532cfc23037e08ff16ef36fdbde57dda122946bba1f71c0a')

build() {
  cp -r "${_realname//-/_}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
